<?php header("Content-Type: text/html; charset=ISO-8859-1",true);
include "../conexao.php";

session_start();

if (!isset($_SESSION["txt_login"]) and !isset($_SESSION["txt_senha"])) 

{

  	print "<script type = 'text/javascript'> location.href = 'index.php'</script>";

}

 ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
	font-family: Arial, Helvetica, sans-serif;
	font-weight: bold;
	font-size: 14px;
	color:#FFFFFF;
}
-->
</style>
<link href="estilo.css" rel="stylesheet" type="text/css" />
</head>

<body><div id="conteudo"><div align="center">
    <h1><strong><font color="red"><u>Lista de Subcategorias</u></font></strong></h1>
  </div>
<table width="99%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    
  </tr>
  <tr>
    
  </tr>
  <tr>
    <td><table width="100%" border="0" cellspacing="2" cellpadding="0">
      <tr>
        <td height="26" colspan="4" background="imagens/img_cat.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="39%" height="24"><div align="center" class="style1"><strong>Categorias </strong></div>
              <div align="center" class="style1"></div>              </td>
            <td width="50%"><div align="center" class="style1"><strong>Subategorias</strong></div>
              <div align="center" class="style1"></div></td>
            <td width="11%" align="center"><strong class="style1">A&ccedil;&atilde;o</strong></td>
            </tr>
        </table></td>
        </tr>
      <tr>
        <td colspan="4"></td>
        </tr><tr>
        <td width="46%" class="cat"><div align="center"><strong>Categorias </strong></div></td>
        <td width="45%" class="cat"><div align="center"><strong>Subcategorias</strong></div></td>
        <td width="4%" class="estilo_L">        </td>
        <td width="5%" align="center" class="estilo_L">        </td>
      </tr>
      <?php  	
	  		$sql = "select c.*, s.* from categoria c, subcategoria s where c.id_categoria = s.id_categoria order by c.categoria";
	   		$resultado= mysql_query($sql);
			while ($coluna = mysql_fetch_array($resultado)) { ?>
             
            
            
            
            
            
      <tr>
        <td width="46%" class="cat"><div align="center"><?php echo $coluna['categoria'] ?></div></td>
        <td width="45%" class="cat"><div align="center"><?php echo $coluna['subcategoria'] ?></div></td>
        <td width="4%" class="estilo_L"><?php if($_SESSION['txt_login']!=""){?>
        <a href="javascript:abre('frm_subcategoria_noticias.php?acao=Alterar&amp;id= <?php echo $coluna['id_subcategoria'];?>','GET')">
        <img src="imagens/alterar.gif" width="16" height="16" border="0" /></a><?php }else{echo "<img src=imagens/alterar.gif onclick=confirmar_exclusao_cat_editar()>";}?>        </td>
        <td width="5%" align="center" class="estilo_L"><?php if($_SESSION['txt_login']!=""){?><a href="javascript:abre('frm_subcategoria_noticias.php?acao=Excluir&amp;id= <?php echo $coluna['id_subcategoria'];?>','GET')"><img src="imagens/excluir.gif" width="16" height="16" border="0" /></a><?php }else{echo "<img src=imagens/excluir.gif onclick=confirmar_exclusao_cat()>";}?>        </td>
      </tr>
      <?php } ?>
      <tr>
        <td colspan="3"><div align="right"> <a href="principal.php?link=5"></a></div></td>
        <td class="estilo_L">
        <?php if(isset($_SESSION["txt_login"])){?>
       
        
        <a href="javascript:abre('frm_subcategoria_noticias.php?acao=Inserir&amp;id=<?php echo $coluna['id_subcategoria'];?>','GET')">
        <img src="imagens/inserir.gif" alt="inserir" width="55" height="16" border = "0"/></a><?php }else{?>
        
        <img src="imagens/inserir.gif" alt="inserir" width="55" height="16" border = "0" onclick="alert('somente o administrador pode inserir subcategorias');"/>
		<?php }?></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table></div>
</body>
</html>
